/*
 * @Description: 
 * @Author: WuShiKang
 * @Date: 2021-04-15 12:20:46
 * @LastEditors: WuShiKang
 * @LastEditTime: 2021-04-15 14:28:10
 */
import axios, { post,get } from '@/utils/request.js'
import { array } from '_jszip@3.2.1@jszip/lib/support';

export default{
    namespaced:true,
    state:{
        baseConfigData:[],
    },
    getters:{},
    mutations:{
        changbaseConfigData(state,payload){
                state.baseConfigData=[];
                state.baseConfigData=payload;
                console.log(payload);
        },
    },
    actions:{
       
        //查找
        async findAllbaseConfig({commit}){
            let res = await axios.get('/baseConfig/findAll');
            commit('changbaseConfigData',res.data);
             },

             //保存
             async saveOrUpdatebaseConfig({dispatch},payload){
             
                let res = await post('/baseConfig/saveOrUpdate',payload);
                return res;
               
               },
               //删除
               async deletebaseById(payload){

                return await get('/baseConfig/deleteById',payload);
                
            },
            async findByKeyName({commit},payload){
                let res=await get('/baseConfig/findByKey',payload);
                array.valueOf()
                   var length = res.data.length;
                       var arr = [{}];
                  for (var i = 0; i < length; i++) {
                    arr.push(res.data[i]);
                       }
                
                commit('changbaseConfigData',arr);
            },
       }
}